import { useEffect } from "react";
import { useParams,Link } from "react-router-dom";
import { Tabs } from 'antd';
import type { TabsProps } from 'antd';
import GroupBuyInfo from "../../../componets/GroupBuyInfo";
import ShopList from "../../../componets/ShopList";
import ProductList from "../../../componets/ProductList";
import { useState } from "react";
import { getGroupBuy } from "../../../api/purchase";
const onChange = (key: string) => {
  console.log(key);
};


function GroupBuyDetail() {
  const [groupInfo,setGroupInfo] = useState({})
  const params = useParams();
  useEffect(()=>{
    getGroupBuy({id:params.id})
    .then(res=>{
        setGroupInfo(res.data.data[0])
        console.log(res.data.data[0])
    })
  },[])
  const items: TabsProps['items'] = [
    {
      key: '1',
      label: `活动信息`,
      children: <GroupBuyInfo groupInfo={groupInfo} ></GroupBuyInfo>,
    },
    {
      key: '2',
      label: `商品列表`,
      children: <ProductList groupInfo={groupInfo}></ProductList>,
    },
    {
      key: '3',
      label: `店铺列表`,
      children: <ShopList groupInfo={groupInfo}/>,
    },
  ];

  return (<div>
    <h3><Link to="/admin/channel/communityPurchase">←返回</Link>活动详情</h3>
    <Tabs defaultActiveKey="1" items={items} onChange={onChange} />
  </div>);
}

export default GroupBuyDetail;